<template>
  <div class="app-container">
    <el-form ref="form" l-form :model="form" label-width="120px">
      <el-form-item style="width: 500px;" label="通告主题 ">
        <el-input v-model="form.content" />
      </el-form-item>
      <el-form-item label="题目类型">
        <el-select v-model="form.region">
          <el-option label="考试" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="发布时间" for="publishDate">
        <input id="publishDate" v-model="announcement.publishDate" type="datetime-local" required>

      </el-form-item>
      <el-form-item label="选择发布班级">
        <el-radio-group v-model="radio">
          <el-radio :label="3">2201</el-radio>
          <el-radio :label="6">2202</el-radio>
          <el-radio :label="9">2203</el-radio>
          <el-radio :label="12">2204</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-button type="primary" style="width:100%;margin-bottom:30px;" @click="onSubmit">发布通知</el-button>
    </el-form>
  </div>
</template>

<script>
import { updateData } from '@/api/teacher';

export default {
  data() {
    return {
      form: {
        region:'',
        radio:'',
        account:'',
        content:'',
      },
      announcement: {
        title: '',
        type: 'news', // 默认类型为新闻
        content: '',
        publishDate: ''
      },
      value1: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
      value2: '',
      num: 1,
      radio: 1
    }
  },
  methods: {
    async onSubmit() {
      // 在这里添加提交逻辑，比如发送一个POST请求到后端API
      console.log('submitting form:', this.form);
      const res = await updateData(this.form)
      console.log(res);
      // 示例：使用axios发送数据到后端API
      // 确保已安装axios库（npm install axios）并导入axios
      // import axios from 'axios';

      // 发送POST请求
      // axios.post('/api/feedback', {
      //   feedback: this.form.summaryFeedback,
      // })
      // .then(response => {
      //   console.log('Feedback submitted successfully:', response.data);
      //   // 可以在此处处理成功的响应，如弹出提示、重置表单等
      // })
      // .catch(error => {
      //   console.error('Error submitting feedback:', error);
      //   // 处理错误情况，如网络问题、后端返回错误等
      // });

      // 如果您没有使用axios，也可以使用fetch API 或 Vue-resource 等其他HTTP客户端。
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    },
    handleChange(value) {
      console.log(value)
    }
    
  }
}
</script>

  <style scoped>
  .line{
    text-align: center;
  }
  </style>
